package com.itheima.mall.web.oms;

import com.itheima.mall.pojo.oms.OmsOrderReturnApply;

import com.itheima.mall.service.oms.OrderReturnApplyService;
import com.itheima.mall.vo.PageResult;
import com.itheima.mall.vo.R;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("returnApply")
public class OrderReturnApplyController {
    @Autowired
    private OrderReturnApplyService orderReturnApplyService;

   /* *
     * 批量删除退货申请
     * @return*/


    @PostMapping("delete")
    public R deleteOrderByIds(@RequestParam(value = "ids") Integer[] ids){
        orderReturnApplyService.deleteApplyByIds(ids);
        return R.succeed(null,null);
    }

    /**
     * 分页查询退货申请
     * @param createTime
     * @param handleMan
     * @param handleTime
     * @param id
     * @param pageNum
     * @param pageSize
     * @param receiverKeyword
     * @param status
     * @return
     */
    @GetMapping("list")
    public R selectReturnApply(String createTime, String handleMan, String handleTime, Integer id,
                                Integer pageNum, Integer pageSize, String receiverKeyword, Integer status){
        PageResult pageResult = orderReturnApplyService.selectReturnApply(createTime,handleMan,handleTime,id,pageNum,pageSize,receiverKeyword,status);
        return R.succeed(pageResult,null);
    }

    @PostMapping("update/status/{id}")
    public R updateStatus(@RequestParam OmsOrderReturnApply omsOrderReturnApply){
        orderReturnApplyService.updateStatus(omsOrderReturnApply);
        return R.succeed(null,null);
    }

    @GetMapping("/{id}")
    public R getReturnApply(@PathVariable Integer id){
        OmsOrderReturnApply omsOrderReturnApply = orderReturnApplyService.getReturnApply(id);
        String message = "操作成功";
        return R.succeed(omsOrderReturnApply,"操作成功");
    }

}
